<?php

declare(strict_types=1);

namespace App\CustHub\Listener;

use App\CustHub\Constants\SyncTaskStatusConstants;
use App\CustHub\Model\ChSyncTask;
use App\CustHub\Service\ChRoomService;
use App\CustHub\Service\ChRoomSyncService;
use App\CustHub\Service\LowQueueService;
use App\Robot\Dto\CommonJobDto;
use App\Robot\Job\CommonJob;
use App\Robot\Job\SyncTaskJob;
use App\Robot\Service\SendRobotMessageService;
use Hyperf\Coroutine\Coroutine;
use Hyperf\Event\Annotation\Listener;
use Hyperf\Event\Contract\ListenerInterface;
use Hyperf\Framework\Event\BootApplication;
use function Hyperf\Coroutine\co;

#[Listener]
class BootApplicationListener implements ListenerInterface
{
    /**
     * @return string[] returns the events that you want to listen
     */
    public function listen(): array
    {
        return [
            BootApplication::class,
        ];
    }

    /**
     * Handle the Event when the event is triggered, all listeners will
     * complete before the event is returned to the EventDispatcher.
     */
    public function process(object $event): void
    {
        if(env('DISTRIBUTE_SERVER_ID') == 'wschat_01'){
            stdout_log()->info('程序启动后重新执行中断的任务');
            container()->get(LowQueueService::class)->push(new CommonJob(new CommonJobDto(
                classname: ChRoomService::class,
                method: 'reSync',
                data: []
            )),60);
        }
    }

}